﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MuseLibrary.Packets
{
    public class UncompressedEegPacket : Packet
    {
        internal UncompressedEegPacket()
        {
            _rawData = new List<int>(6);
            _hasPostInitialisation = true;
            _channels = new int[4];
        }

        #region Methods

        protected override void DoInitialisation()
        {
            var processedValues = (HasFlags) ? _rawData.To10BitIntegers(3, 4) : _rawData.To10BitIntegers(1, 4);

            _channels[0] = processedValues[0];
            _channels[1] = processedValues[1];
            _channels[2] = processedValues[2];
            _channels[3] = processedValues[3];
        }

        public override void PostInitialisation(int[] _channelValues)
        {
            for (int i = 0; i < 4; i++)
                _channelValues[i] = _channels[i];
        }

        #endregion

        #region Properties

        public override PacketType Type
        {
            get { return PacketType.UncompressedEeg; }
        }

        public int[] Channels
        {
            get { return _channels; }
        }

        public override int Length
        {
            get
            {
                return (HasFlags) ? 8 : 6;
            }
        }

        #endregion

        #region Fields

        private int[] _channels;

        #endregion
    }
}
